<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="util.*"%>
<%@page import="dal.*,bll.*"%>
<%@page import="model.*,java.util.*"%>
<%
// 	int accType = 2;
// 	String username = (String)session.getAttribute("username");
// 	String pass = (String)session.getAttribute("password");
	
// 	if(username != null && pass != null)
// 	{
// 		AccountModel acc = new AccountModel();
// 		accType = acc.CheckLogin(username, pass); // Value can be: 0: manager, 1: user, 2: no-account
// 	}	
// 	if(accType == 2) {
// 		response.sendRedirect("Login.jsp");
// 	}
// 	else {
// 		session.setAttribute("login-in", "true");
// 	}
		
	boolean logined = AuthenticationUtil.checkLogin(session);
	if(logined) {
		session.setAttribute("login-in", "true");
	}
	else {
		response.sendRedirect("Login.jsp");
	}
	String username = AuthenticationUtil.getUserName(session);
	boolean isDirector = AuthenticationUtil.isDirectorLogined(session);
%>
<%	
	int lastProjectId = CacheUtil.getLastProjectId(); 
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title></title>

	<link rel="stylesheet" type="text/css" href="css/header-menu.css" />
	<script type="text/javascript">
		var allSubMenusToHide = ['sub-links-PM', 'sub-links-CRM', 'sub-links-HRM', 'sub-links-SCM', 
									'sub-links-CMS', 'sub-links-FAM', 'sub-links-OTHERS'];
		
		function activateSubMenu(id)
		{
			deactivateAllSubMenus();
			document.getElementById(id).style.visibility = "visible";
		}
		
		function deactivateSubMenu(id)
		{
			document.getElementById(id).style.visibility = "hidden";
		}
		
		function deactivateAllSubMenus()
		{
			for(i = 0; i < allSubMenusToHide.length; i++)
			{
				subMenuId = allSubMenusToHide[i];
				//alert(subMenuId);
				deactivateSubMenu(subMenuId);
			}
		}
	</script>
</head>
<body>
	<table class="tblHeaderMenu">
		<tr>
			<td class="tblHeaderMenu left"></td>
			<td class="tblHeaderMenu center">
				<table cellspacing="0" cellpadding="0"><tr>
					<td style="vertical-align:top;">
						<img src="images-interface/logo.gif" align="top" height="90" alt="" border="0"/></td>
					<td class="tblHeaderMenu greeting">
						<span>Hello <b><%=username%></b></span>
						<br/>
						<span><a href = "Login.jsp?logout=true">Logout </a>| Tutorials | What news?</span>
					</td>
					<td width="700px" class="tblHeaderMenu navigator">
						<div id="sup-links">
							<a href="<%if(isDirector){%>manager.jsp<%} else{%>index.jsp<%}%>"><span onmouseover="deactivateAllSubMenus();">HOME</span></a>
							<%
								if(AuthorizationBll.checkMenuRight(Enums.Menu.PM.getId(), session))
								{
							%>							
							<a href="phase.jsp?idProject=<%=lastProjectId%>" title="PM"><span style="width:20px;" onmouseover="activateSubMenu('sub-links-PM');">PM</span></a>
							<%
								}
							%>
							<a href=""><span style="width:35px;" onmouseover="activateSubMenu('sub-links-CRM');">CRM</span></a>
							<a href=""><span style="width:35px;" onmouseover="activateSubMenu('sub-links-HRM');">HRM</span></a>
							<a href=""><span style="width:35px;" onmouseover="activateSubMenu('sub-links-SCM');">SCM</span></a>
							<a href=""><span style="width:35px;" onmouseover="activateSubMenu('sub-links-CMS');">CMS</span></a>
							<a href=""><span style="width:35px;" onmouseover="activateSubMenu('sub-links-FAM');">FAM</span></a>
							<a href=""><span style="width:60px;" onmouseover="activateSubMenu('sub-links-OTHERS');">OTHERS</span></a>						
						</div>
						<div id="sub-links">
							<div id="sub-links-PM" style="width: 620px;">
								<a href="projectNew.jsp"><span>New Project</span></a>
								<a href="projectList.jsp"><span>Project</span></a>
								<a href="phaseList.jsp"><span>Phase</span></a>
								<a href="quotationList.jsp"><span>Quotation</span></a>
								<a href="agendaList.jsp"><span>Agenda</span></a>
								<a href="checklistList.jsp"><span>Checklist</span></a>
								<a href="eventList.jsp"><span>Event</span></a>
								<a href="checklistItemList.jsp"><span>Task</span></a>
								<a href="riskList.jsp"><span>Risk</span></a>
								<a href="issueList.jsp"><span>Issue</span></a>
								<a href="changeRequestList.jsp"><span>Change</span></a>
							</div>
							<div id="sub-links-CRM" style="text-align: left; padding-left: 314px; width: 375px;">
								<a href="personList.jsp"><span>Person</span></a>
								<a href="companyList.jsp?role=1"><span>Client</span></a>
								<a href="companyList.jsp?role=2"><span>Competitor</span></a>
								<a href="companyList.jsp?role=3"><span>Broker</span></a>
								<a href="activityList.jsp?role=3"><span>Activity</span></a>
							</div>
							<div id="sub-links-HRM" style="text-align: left; padding-left: 350px; width: 300px;>
								<a href="employeeList.jsp"><span>Employee</span></a>
								<a href="workload.jsp"><span>Workload</span></a>
								<a href="performance.jsp"><span>Performance</span></a>
							</div>							
							<div id="sub-links-SCM" style="text-align: left; padding-left: 408px; width: 292px;">
								<a href="productList.jsp"><span>Product</span></a>
								<a href="serviceList.jsp"><span>Service</span></a>
								<a href="purchaseList.jsp"><span>Purchase</span></a>
								<a href="companyList.jsp?role=4"><span>Supplier</span></a>
								<a href=supplyList.jsp"><span>Supply</span></a>
							</div>
							<div id="sub-links-CMS" style="text-align: left; padding-left: 500px; width: 300px;">
								<a href="documentList.jsp"><span>Document</span></a>
								<a href="documentTypeList.jsp"><span>Document Type</span></a>
							</div>
							<div id="sub-links-FAM">
								<a href="cashflow.jsp"><span>Cash flow</span></a>
								<a href="receivableList.jsp"><span>Receivable</span></a>
								<a href="payment.jsp"><span>Payment</span></a>
								<!--								
								<a href=""><span>Payable</span></a>
								<a href=""><span>Receivable</span></a>
								<a href=""><span>Cash advance</span></a>
								<a href=""><span>Cash issue</span></a>
								<a href=""><span>Cash receipt</span></a>
								  -->																
							</div>
							<div id="sub-links-OTHERS">
								<a href="companyList.jsp?role=0"><span>Company</span></a>								
								<a href="venueList.jsp"><span>Venue</span></a>
								<a href="unitList.jsp"><span>Unit</span></a>
								<a href="placeList.jsp"><span>Place</span></a>								
<!-- 							<a href=""><span>Help</span></a> -->
							</div>
						</div>
					</td>
				</tr></table>
			</td>
			<td class="tblHeaderMenu right"></td>
		</tr>
	</table>
</body>
</html>